#include <iostream>
#include <string>
#include <stack>
#include <algorithm>

using namespace std;

class Solution {
public:
    bool isPalindrome(string s) {
		if(s=="" ) return true;
		transform(s.begin(), s.end(), s.begin(), ::tolower);
		auto left = s.begin();
		auto right = prev(s.end());
		while(left<right)
		{
			if(!::isalnum(*left)) ++left;
			else if(!::isalnum(*right)) --right;
			else if(*left != *right) return false;
			else
			{
				left++;
				right--;
			}
		}
		return true;
        
    }
};

class Solution {
public:
    bool isPalindrome(string s) {
		vector<char> x;
		for(size_t i=0;i<s.size();i++)
		{
			if(::isalpha(s[i]))
			{
				x.push_back(::tolower(s[i]));
			}
			else if(::isdigit(s[i]))
			{
				x.push_back(s[i]);
			}
		}
		for(size_t i=0;i<x.size()/2;i++)
		{
			if(x[i]!=x[x.size()-i-1])
				return false;
		}
		return true;
		
    }
};

int main(){
	Solution s;
	string str = "abcba";
	cout<<s.isPalindrome(str)<<endl;



	getchar();
    return 0;
}
